package com.cos.hospital.widget;

import android.content.Context;
import android.support.constraint.ConstraintLayout;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.cos.hospital.R;
import com.liaoinstan.springview.utils.DensityUtil;

public class TabItemView extends ConstraintLayout {

    View circleView;
    TextView labelT, personT;
    ImageView imageI;
    boolean isSelect = false;
    float width16, width12, width14;

    public TabItemView(Context context) {
        this(context, null);
    }

    public TabItemView(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public TabItemView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        LayoutInflater.from(getContext()).inflate(R.layout.layout_tab_item, this);
        circleView = findViewById(R.id.circle_icon);
        labelT = findViewById(R.id.label_content);
        personT = findViewById(R.id.person_num);
        imageI = findViewById(R.id.triangle_icon);
        width16 =16;
        width12 = 12;
        width14 = 14;
        refreshView();
    }

    public void setSelect(boolean isSelect) {
        this.isSelect = isSelect;
        refreshView();
    }

    private void refreshView() {
        if (isSelect) {
            circleView.setVisibility(VISIBLE);
            imageI.setVisibility(VISIBLE);
            labelT.setTextSize(width16);
            personT.setTextSize(width12);
        } else {
            imageI.setVisibility(INVISIBLE);
            circleView.setVisibility(INVISIBLE);
            labelT.setTextSize(width14);
            personT.setTextSize(width12);
        }
        labelT.setSelected(isSelect);
        personT.setSelected(isSelect);
    }

    public void setLabelContent(String str) {
        this.labelT.setText(str);
    }

    public void setPersonNum(int str) {
        this.personT.setText(str+"人");
    }
}

